﻿using MaterialDesignThemes.Wpf;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 基于WPF的电缆采样数据分析系统.Service;
using 基于WPF的电缆采样数据分析系统.Tools.LangugeTool;

namespace 基于WPF的电缆采样数据分析系统.ViewModels.Settings
{
    public class UpdateUserUCViewModel : BindableBase, IDialogHostAware
    {

        // 主机名
        private const string DialogHostName = "RootDialog";

        #region 确定
        /// <summary>
        /// 确定命令
        /// </summary>
        public DelegateCommand SaveCommand { get; set; }

        /// <summary>
        /// 确定方法
        /// </summary>
        private void SaveFun()
        {
            if (DialogHost.IsDialogOpen(DialogHostName))
            {
                DialogHost.Close(DialogHostName, new DialogResult(ButtonResult.Yes));
            }
        }
        #endregion

        #region 取消
        /// <summary>
        /// 取消命令
        /// </summary>
        public DelegateCommand CancelCommand { get; set; }

        /// <summary>
        /// 取消方法
        /// </summary>
        private void CancelFun()
        {
            if (DialogHost.IsDialogOpen(DialogHostName))
            {
                DialogHost.Close(DialogHostName, new DialogResult(ButtonResult.No));
            }
        }
        #endregion

        /// <summary>
        /// 打开过程中
        /// </summary>
        /// <param name="parameters"></param>
        public void OnDialogOpening(IDialogParameters parameters)
        {
            PageTitle = parameters.GetValue<string>("title");
            Text1 = parameters.GetValue<string>("Text1");
            Text2 = LangugeConvertor.GetValue("S_Alias");
            Alias = parameters.GetValue<string>("Alias");
            Text3 = LangugeConvertor.GetValue("S_User");
        }

        /// <summary>
        /// 构造器
        /// </summary>
        public UpdateUserUCViewModel()
        {
            //绑定确定和取消命令
            SaveCommand = new DelegateCommand(SaveFun);
            CancelCommand = new DelegateCommand(CancelFun);
        }

        #region 页面信息
        /// <summary>
        /// 标题
        /// </summary>
        private string _PageTitle;

        /// <summary>
        /// 标题
        /// </summary>
        public string PageTitle
        {
            get { return _PageTitle; }
            set
            {
                _PageTitle = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 文本一
        /// </summary>
        private string _Text1;

        /// <summary>
        /// 文本一
        /// </summary>
        public string Text1
        {
            get { return _Text1; }
            set { 
                _Text1 = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 文本二
        /// </summary>
        private string _Text2;

        /// <summary>
        /// 文本二
        /// </summary>
        public string Text2
        {
            get { return _Text2; }
            set { 
                _Text2 = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 别名
        /// </summary>
        private string _Alias;

        /// <summary>
        /// 别名
        /// </summary>
        public string Alias
        {
            get { return _Alias; }
            set { 
                _Alias = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 文本三
        /// </summary>
        private string _Text3;

        /// <summary>
        /// 文本三
        /// </summary>
        public string Text3
        {
            get { return _Text3; }
            set { 
                _Text3 = value;
                RaisePropertyChanged();
            }
        }


        #endregion
    }
}
